package cn.caplike.demo.rabbitmq.springboot.idempotence_reliability.domain.model;

import com.alibaba.fastjson.JSON;

/**
 * Description: {@link MessageDeliveryLog} 构建器
 *
 * @author LiKe
 * @version 1.0.0
 * @date 2020-09-02 15:19
 */
public class MessageDeliveryLogBuilder {

    private final MessageDeliveryLog target = new MessageDeliveryLog();

    private MessageDeliveryLogBuilder() {
    }

    public static MessageDeliveryLogBuilder of() {
        return new MessageDeliveryLogBuilder();
    }

    public MessageDeliveryLogBuilder messageId(String messageId) {
        target.setMessageId(messageId);
        return this;
    }

    public MessageDeliveryLogBuilder message(Object message) {
        target.setMessage(JSON.toJSONString(message));
        return this;
    }

    public MessageDeliveryLogBuilder exchange(String exchange) {
        target.setExchange(exchange);
        return this;
    }

    public MessageDeliveryLogBuilder routingKey(String routingKey) {
        target.setRoutingKey(routingKey);
        return this;
    }

    public MessageDeliveryLogBuilder status(int status) {
        target.setStatus(status);
        return this;
    }

    public MessageDeliveryLogBuilder retryCount(int retryCount) {
        target.setRetryCount(retryCount);
        return this;
    }

    public MessageDeliveryLog build() {
        return target;
    }

}
